package ru.myrtle.umf.query.condition;

import ru.myrtle.umf.query.UCondition;

public abstract class UValueCondition<ValueType, ValueAdapterType extends UValueAdapter<ValueType>>
        extends UCondition {

    protected final ValueAdapterType valueAdapter;

    public UValueCondition(ValueAdapterType valueAdapter) {
        this.valueAdapter = valueAdapter;
    }

    protected abstract boolean isSatisfiedImpl(ValueType adapted);

    @Override
    public final boolean isSatisfied(Object object) {
        return isSatisfiedImpl(
                valueAdapter.adapt(object)
        );
    }
}
